#include <iostream>
#include <time.h>
#include <stdlib.h>
using namespace std;

int main()
{
    int i,n,dice=1;
    int cal=1,counter=0,dicecount=0;
    srand(time(NULL));
    cout<<"how many kids: n=";
    cin>>n;
    cout<<endl;
    int kid[n+1];
    for(i=0;i<n;i++)
        kid[i]=100;
    kid[i]=-10;
    for(i=0;counter!=(n-1);i++)
    {
        if(kid[i]==-10)
        {
            i=-1;
            continue;
        }
        if(kid[i]<=0)
        {
            continue;
        }
        if(cal==dice)
        {
            dicecount++;
            dice=rand()%6+1;
            cout<<"It's the result of No."<<dicecount<<" dicing: "<<dice<<endl;
            kid[i]-=10*(6-dice);
            cout<<"Now the No."<<i+1<<" kid's score becomes "<<kid[i]<<endl<<endl;
            if(kid[i]<=0)
            {
                counter++;
                cout<<"The No."<<i+1<<" kid is out!"<<endl<<endl;
            }
            cal=1;
            continue;
        }
        cal++;
    }
    for(i=0;i<n;i++)
    {
        if(kid[i]<=0)
        {
            continue;
        }
        else
        {
            cout<<"The final winner is born: the No."<<i+1<<" kid!"<<endl;
            cout<<"And his/her score is "<<kid[i]<<endl<<endl;
            break;
        }
    }

    return 0;
}

